package cn.server.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.server.IConfigure;
import cn.server.IServer;
import cn.server.conf.ServerParam;

public abstract class AbstractServer implements IServer {

	protected IConfigure conf = null;
	
	protected ServerParam param = null;

	private static final Log logger = LogFactory.getLog(AbstractServer.class);

	public void start() {
		init();
		startServer();
	}

	@Override
	public void setConfClass(String name) {
		try {
			conf = (IConfigure) Class.forName(name).newInstance();
		} catch (Throwable e) {
			logger.error("error init conf class", e);
			System.err.println("error init conf class!");
		}
	}

	@Override
	public void setParam(ServerParam param) {
		this.param = param;
	}

	public abstract void init();

	public abstract void startServer();
}
